using Logger4Net;
using System.Configuration;

namespace Hubberly.Config
{
   public class Hubberly : Utilities.Archive
   {
      public static readonly string CONFIG_SECTION = "hubberly";

      ////////////////////////////////////////////////////////////////////////
      //
      public Hubberly()
      {
         try
         {
            Properties.Add(mru_);
            Properties.Add(showGoods_);
            Properties.Add(groupByHub_);
            Properties.Add(worldFilename_);
            mru = new Utilities.MRUArchive();
         }
         catch (System.Exception ex)
         {
            logger_.exception(ex);
         }
      }

      ////////////////////////////////////////////////////////////////////////
      //
      [ConfigurationProperty("mru")]
      public Utilities.MRUArchive mru
      {
         get { return (Utilities.MRUArchive)base[mru_]; }
         set { base[mru_] = value; }
      }

      ////////////////////////////////////////////////////////////////////////
      //
      [ConfigurationProperty("showGoods")]
      public Main.ShowGoodsIndices showGoods
      {
         get { return (Main.ShowGoodsIndices)base[showGoods_]; }
         set { base[showGoods_] = value; }
      }

      ////////////////////////////////////////////////////////////////////////
      //
      [ConfigurationProperty("groupByHub")]
      public bool groupByHub
      {
         get { return (bool)base[groupByHub_]; }
         set { base[groupByHub_] = value; }
      }

      ////////////////////////////////////////////////////////////////////////
      //
      [ConfigurationProperty("worldFilename")]
      public string worldFilename
      {
         get { return (string)base[worldFilename_]; }
         set { base[worldFilename_] = value; }
      }

      ////////////////////////////////////////////////////////////////////////
      //
      private ConfigurationProperty mru_ = new ConfigurationProperty("mru", typeof(Utilities.MRUArchive), null);
      private ConfigurationProperty showGoods_ = new ConfigurationProperty("showGoods", typeof(Main.ShowGoodsIndices), Main.ShowGoodsIndices.All);
      private ConfigurationProperty groupByHub_ = new ConfigurationProperty("groupByHub", typeof(bool), true);
      private ConfigurationProperty worldFilename_ = new ConfigurationProperty("worldFilename", typeof(string), string.Empty);
   }
}
